package com.horay.springbootdemo.jwt.common.jwt;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.horay.springbootdemo.jwt.common.model.Customer;

import java.util.Date;

/**
 * JWT工具类
 *
 * @author heyingcheng
 * @date 2019/10/4 12:04
 */
public class JwtUtils {

    public static String token(Customer customer) {
        String token = JWT.create().withAudience(customer.getId()).withExpiresAt(new Date(System.currentTimeMillis() + (30 * 60 * 1000))).sign(Algorithm.HMAC256(customer.getPassword()));
        return token;
    }

}
